﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace game
{
    public class MeteorPlane : GameObject
    {

        public MeteorPlane(Scene scene, int layerIndex)
            : base(scene, layerIndex)
        {
            World = Matrix.Identity;
            vertexDecl = new VertexDeclaration(ShooterGame.Instance.GraphicsDevice,
                VertexPositionColor.VertexElements);
        }


        protected VertexPositionColor[] plane = new VertexPositionColor[4]{
            new VertexPositionColor((new Vector3(-100,0,-100)), new Color(255,255,255)),
            new VertexPositionColor((new Vector3(-100,0,100)), new Color(255,0,0)),
            new VertexPositionColor((new Vector3(100,0,100)), new Color(0,0,255)),
            new VertexPositionColor((new Vector3(100,0,-100)), new Color(0,0,255)),
        };

        protected VertexDeclaration vertexDecl;

        public override void DrawOpaque(GameTime gameTime)
        {
            BasicEffect effect = ShooterGame.Instance.BasicEffect;

            ShooterGame.Instance.GraphicsDevice.VertexDeclaration = vertexDecl;

            effect.PreferPerPixelLighting = true;
            effect.VertexColorEnabled = true;
            effect.EnableDefaultLighting();
            effect.World = Matrix.Identity;
            effect.View = scene.ActiveCamera.View;
            effect.Projection = scene.ActiveCamera.Projection;

            effect.Begin();

            ShooterGame.Instance.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleFan, plane, 0, 2);

            effect.End();

        }
    }


}
